package com.yfp.client.controller;

import com.yfp.client.domain.ClientMachineFavorites;
import com.yfp.client.domain.vo.ClientMachineFavoritesVo;
import com.yfp.client.service.ClientMachineFavoritesService;
import com.yfp.client.util.Response;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 客户收藏
 *
 * @CreateDate: 2024/5/23 16:53
 * @UpdateUser:
 * @UpdateDate: 2024/5/23 16:53
 * @UpdateRemark: 暂无修改
 * @Version: 1.0
 */
@RestController
@RequestMapping("/client/favorites")
@Tag(name = "客户端设备收藏")
public class ClientMachineFavoritesCotroller {
    @Autowired
    private ClientMachineFavoritesService clientMachineFavoritesService;

    @Operation(summary = "查询客户收藏")
    @GetMapping("")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK"),
    })
    @ApiOperation(value = "客户收藏列表", notes = "客户收藏列表", response = ClientMachineFavoritesVo.class)
    public Response<List<ClientMachineFavoritesVo>> findClientMachineFavorites(String clientId, String latitude, String longitude) {
        List<ClientMachineFavoritesVo> clientMachineFavorites = clientMachineFavoritesService.findClientMachineFavorites(clientId, latitude, longitude);
        clientMachineFavoritesService.findClientMachineFavoritesComplement(clientMachineFavorites);
        return Response.success(clientMachineFavorites);
    }


    @Operation(summary = "客户收藏")
    @PostMapping("")
    public Response favorites(@RequestBody ClientMachineFavorites clientMachineFavorites) {
        clientMachineFavoritesService.favorites(clientMachineFavorites);
        return Response.success();
    }

}
